<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<link rel="stylesheet" type="text/css" media="screen" href="../../css/bootstrap.min.css">
</head>
<body>
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
	<form class="form-horizontal" onsubmit="return false" id="form">
		<fieldset>
			<input type="hidden" id="id" name="id">
			<div class='form-group'>
				<label class='col-md-2 control-label'>supItemNo</label>
				<div class='col-md-10'>
					<input class='form-control' placeholder='supItemNo' type='text' name='supItemNo' id='supItemNo' data-bv-notempty='true' data-bv-notempty-message='supItemNo 不能为空'>
				</div>
			</div>
			<div class='form-group'>
				<label class='col-md-2 control-label'>itemNo</label>
				<div class='col-md-10'>
					<input class='form-control' placeholder='itemNo' type='text' name='itemNo' id='itemNo' data-bv-notempty='true' data-bv-notempty-message='itemNo 不能为空'>
				</div>
			</div>
			<div class='form-group'>
				<label class='col-md-2 control-label'>supplierNo</label>
				<div class='col-md-10'>
					<input class='form-control' placeholder='supplierNo' type='text' name='supplierNo' id='supplierNo' data-bv-notempty='true' data-bv-notempty-message='supplierNo 不能为空'>
				</div>
			</div>
			<div class='form-group'>
				<label class='col-md-2 control-label'>goodsType</label>
				<div class='col-md-10'>
					<input class='form-control' placeholder='goodsType' type='text' name='goodsType' id='goodsType' data-bv-notempty='true' data-bv-notempty-message='goodsType 不能为空'>
				</div>
			</div>
			<div class='form-group'>
				<label class='col-md-2 control-label'>goodsName</label>
				<div class='col-md-10'>
					<input class='form-control' placeholder='goodsName' type='text' name='goodsName' id='goodsName' data-bv-notempty='true' data-bv-notempty-message='goodsName 不能为空'>
				</div>
			</div>
			<div class='form-group'>
				<label class='col-md-2 control-label'>leastBuyQuantity</label>
				<div class='col-md-10'>
					<input class='form-control' placeholder='leastBuyQuantity' type='text' name='leastBuyQuantity' id='leastBuyQuantity' data-bv-notempty='true' data-bv-notempty-message='leastBuyQuantity 不能为空'>
				</div>
			</div>
			<div class='form-group'>
				<label class='col-md-2 control-label'>buyUnit</label>
				<div class='col-md-10'>
					<input class='form-control' placeholder='buyUnit' type='text' name='buyUnit' id='buyUnit' data-bv-notempty='true' data-bv-notempty-message='buyUnit 不能为空'>
				</div>
			</div>
			<div class='form-group'>
				<label class='col-md-2 control-label'>brand</label>
				<div class='col-md-10'>
					<input class='form-control' placeholder='brand' type='text' name='brand' id='brand' data-bv-notempty='true' data-bv-notempty-message='brand 不能为空'>
				</div>
			</div>
			<div class='form-group'>
				<label class='col-md-2 control-label'>specific</label>
				<div class='col-md-10'>
					<input class='form-control' placeholder='specific' type='text' name='specific' id='specific' data-bv-notempty='true' data-bv-notempty-message='specific 不能为空'>
				</div>
			</div>
			<div class='form-group'>
				<label class='col-md-2 control-label'>place</label>
				<div class='col-md-10'>
					<input class='form-control' placeholder='place' type='text' name='place' id='place' data-bv-notempty='true' data-bv-notempty-message='place 不能为空'>
				</div>
			</div>
			<div class='form-group'>
				<label class='col-md-2 control-label'>property</label>
				<div class='col-md-10'>
					<input class='form-control' placeholder='property' type='text' name='property' id='property' data-bv-notempty='true' data-bv-notempty-message='property 不能为空'>
				</div>
			</div>
			<div class='form-group'>
				<label class='col-md-2 control-label'>preBuyPrice</label>
				<div class='col-md-10'>
					<input class='form-control' placeholder='preBuyPrice' type='text' name='preBuyPrice' id='preBuyPrice' data-bv-notempty='true' data-bv-notempty-message='preBuyPrice 不能为空'>
				</div>
			</div>



			<div class="form-actions">
				<div class="row" align="center">
					<div class="col-md-12">
					    <button class="btn btn-primary" onclick="location.href='pSupplierGoodsList.html'">返回</button>
						<button class="btn btn-primary" type="submit" onclick="update()">
							<i class="fa fa-save"></i> 保存
						</button>
					</div>
				</div>
			</div>

		</fieldset>
	</form>
</div>
	<script type="text/javascript" src="../../js/libs/jquery-2.1.1.min.js"></script>
	<script type="text/javascript" src="../../js/jq.js"></script>
	<script type="text/javascript" src="../../js/plugin/bootstrapvalidator/bootstrapValidator.min.js"></script>
	<script type="text/javascript" src="../../js/common.js"></script>
	<script type="text/javascript" src="../../layui/layui.js"></script>
	<script type="text/javascript">
		layui.use(['layer','laydate'], function(){
		    var layer = layui.layer;
		});
		
		initData();
		
		function initData(){
			var id = getUrlParam("id");
			if(id != ""){
				$.ajax({
					type : 'get',
					url : '/pSupplierGoodss/'+id,
					async : false,
					success : function(data) {
						$('#id').val(data.id);
						$('#supItemNo').val(data.supItemNo);
						$('#itemNo').val(data.itemNo);
						$('#supplierNo').val(data.supplierNo);
						$('#goodsType').val(data.goodsType);
						$('#goodsName').val(data.goodsName);
						$('#leastBuyQuantity').val(data.leastBuyQuantity);
						$('#buyUnit').val(data.buyUnit);
						$('#brand').val(data.brand);
						$('#specific').val(data.specific);
						$('#place').val(data.place);
						$('#property').val(data.property);
						$('#preBuyPrice').val(data.preBuyPrice);
						$('#createTime').val(data.createTime);
						$('#updateTime').val(data.updateTime);

					}
				});
			}
		}

		function update() {
			$('#form').bootstrapValidator();
			var bootstrapValidator = $("#form").data('bootstrapValidator');
			bootstrapValidator.validate();
		    if(!bootstrapValidator.isValid()){
			   return;
		    }
		    
		    var formdata = $("#form").serializeObject();

			$.ajax({
				type : 'put',
				url : '/pSupplierGoodss',
				contentType: "application/json; charset=utf-8",  
				data : JSON.stringify(formdata),
				success : function(data) {
					layer.msg("修改成功", {shift: -1, time: 1000}, function(){
                        location.href = "pSupplierGoodsList.html";
                    });
				}
			});
		}
		
	</script>
</body>
</html>
